<template>
    <div class="foot">
        <div class="my-div">
            <a-form :model="params" name="basic" :label-col="{ span: 8 }">
                <a-row>
                    <a-col :pull="6" :span="24">
                        <a-form-item label="工程复杂经过" name="complexPassage">
                            <a-textarea v-model:value="params.complexPassage"  
                            style="width: 100%" :rows="3" />
                        </a-form-item>
                    </a-col>
                    <a-col :pull="6" :span="24">
                        <a-form-item label="初步原因分析" name="causeAnalysis">
                            <a-textarea v-model:value="params.causeAnalysis" style="width: 100%" :rows="3" 
                            />
                        </a-form-item>
                    </a-col>
                    <a-col :pull="6" :span="24">
                        <a-form-item label="井筒状况" name="wellboreCondition">
                            <a-textarea v-model:value="params.wellboreCondition" style="width: 100%" :rows="3" />
                        </a-form-item>
                    </a-col>
                    <a-col :pull="6" :span="24">
                        <a-form-item label="下步处置方案" name="nextSteps">
                            <a-textarea v-model:value="params.nextSteps" style="width: 100%" :rows="3" />
                        </a-form-item>
                    </a-col>
                </a-row>
                <a-row>
                    <!-- <a-col :span="6">
                        <a-form-item label="填报人" name="fillPeople">
                            <a-input style="width: 200px" v-model:value="params.fillPeople" />
                        </a-form-item>
                    </a-col> -->
                    <a-col :span="6">
                        <a-form-item label="联系方式" name="phoneNumber">
                            <a-input style="width: 200px" v-model:value="params.phoneNumber" />
                        </a-form-item>
                    </a-col>
                    <a-col :span="6">
                        <a-form-item label="填报单位" name="unit">
                            <a-input style="width: 200px" v-model:value="params.unit" />
                        </a-form-item>
                    </a-col>
                    <!-- <a-col :span="6">
                        <a-form-item label="填报日期" name="fillDate">
                            <a-date-picker v-model:value="params.fillDate" style="width: 200px;" format="YYYY-MM-DD" />
                        </a-form-item>
                    </a-col> -->
                </a-row>
            </a-form>
        </div>
    </div>
    <div class="steps-action">
        <a-button @click="prev">上一步</a-button>
        <a-button style="margin-left: 8px" type="primary" @click="next">完成</a-button>
    </div>
</template>
<script setup>
import moment from "moment";
import "moment/locale/zh-cn"
import dayjs from 'dayjs'
import "dayjs/locale/zh-cn"
import useUserStore from '@/store/modules/user';
import useApp from "@/hooks";
const { $, proxy } = useApp();
const userStore = useUserStore();
const emit = defineEmits(["getCurrent"])
const props = defineProps({
    reportQuery: Object,
    schemesData: Object
})
const params = reactive({
    complexPassage: '该井x月x日晚x点,测完声感和阵列侧向后通井。x月x日凌晨x通井结束后开始进行放射性施工，x月x日9:10仪器下至X米遇阻，正常上提X米后再次尝试下放，上提过程中无挂卡显示。下放至X米后再次遇阻。再次上提活动仪器，到X处遇卡，拉至总张力X磅，未能解卡。反复试拉X次，总张力由X磅涨到X磅，仪器未活动，最终拉至X磅等待穿心解卡。',
    wellboreCondition: 'x月x日进行声感阵列侧向施工时，通井时钻具无挂卡显示。',
    causeAnalysis: '该处为泥岩，地层比较致密，容易垮塌，井径数值变化不大，井斜X度，怀疑掉块导致遇卡。',
    nextSteps: '穿心解卡',
    fillPeople: '',
    phoneNumber: '',
    unit: '',
    fillDate: '',
})

//注入信息
function setNewData(res) {
    for (const key in res) {
        if (res.hasOwnProperty(key) && params.hasOwnProperty(key)) {
            params[key] = res[key];
        }
    }
    //日期处理
    // if (params.fillDate) {
    //     params.fillDate = dayjs(params.fillDate, 'YYYY-MM-DD');
    //     console.log('setNew-fillDate', params.fillDate);
    // }
}
//获取已有信息
function getReportQuery() {
    let state = localStorage.getItem("state");
    if (state === '修改' && !props.reportQuery.hasOwnProperty("cableInformation")) {
        setNewData(props.schemesData);
    } else if (state === "补充") {
        params.wellboreCondition = props.schemesData.abnormalCondition
    } else {
        setNewData(props.reportQuery)
    }
}
getReportQuery()
//下一步
function next() {
    console.log('next-fillDate', params.fillDate);
    userStore.getProfile().then(res => {
        console.log('uesr', res);
        params.fillPeople = res.userName
        let currentTime = new Date()
        params.fillDate = moment(currentTime).format('YYYY-MM-DD')
        params.page = 'submit'
        console.log('next-params', params);
        emit('getCurrent', params)
    })
    // params.fillDate = moment(params.fillDate).format('YYYY-MM-DD')
}
//上一步
function prev() {
    console.log('prev-fillDate', params.fillDate);
    // params.fillDate = moment(params.fillDate).format('YYYY-MM-DD')
    params.page = 1
    emit('getCurrent', params)
}
</script>
<style scoped>
.my-div {
    width: 1370px;
    padding: 10px;
    transform: scaleY(-1);
}

.foot {
    overflow-x: auto;
    transform: scaleY(-1);
}
</style>